﻿<%@ Page Title="Gestionar Acciones" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Acciones.aspx.cs" Inherits="Triunfadores.Web.Acciones.Acciones" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    
    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title">Acciones</h3>
            <div class="box-tools pull-right">
                <a data-toggle="modal" href="#myModal" class="btn btn-primary btn-sm">
                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>Nuevo
                </a>
            </div>
        </div>
        <div class="box-body">
            
            <asp:UpdatePanel ID="upAcciones" runat="server">
                <ContentTemplate>
                    <asp:ListView
                        ID="lvAcciones"
                        ItemType="Triunfadores.BusinessEntities.Accion"
                        runat="server"
                        SelectMethod="ObtenerAcciones">
                        <EmptyDataTemplate>
                            <h3 class="message-error" align="center"><strong>No hay elemtos que mostrar.</strong></h3>
                        </EmptyDataTemplate>
                        <LayoutTemplate>
                            <div class="table-responsive">
                                <table class="table table-hover table-condensed">
                                    <thead style="background: #F6F7F8; color: #3B5998">
                                        <tr>
                                            <th>Precio</th>
                                            <th>Descripción</th>
                                            <th>Acciones</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr id="itemPlaceholder" runat="server"></tr>
                                    </tbody>
                                </table>
                            </div>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <tr>
                                <td><%#Item.Precio %></td>
                                <td><%#Item.Descripcion %></td>
                                <td>
                                    <a class="btn btn-warning btn-xs" href="Acciones.aspx?idAccion=<%#Item.Id %>&opc=editar">
                                        <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
                                    </a>
                                    <a class="btn btn-danger btn-xs" href='Acciones.aspx?idAccion=<%#Item.Id %>&opc=eliminar'
                                        onclick='return confirm("Desea Eliminar este elemento");'>
                                        <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                                    </a>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:ListView>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </div>
    
    <asp:FormView CssClass="col-xs-12" DefaultMode="Edit"
        ID="fvAccion"
        InsertMethod="InsertAccion"
        ItemType="Triunfadores.BusinessEntities.Accion"
        runat="server"
        SelectMethod="ObtenerAccionPorId"
        UpdateMethod="UpdateAccion">
        <InsertItemTemplate>
            <!-- Modal -->
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel">Registrar Tipo Cliente</h4>
                        </div>
                        <div class="modal-body">
                            <asp:TextBox ID="tbxId" runat="server" Text="<%#BindItem.Id %>" Visible="False" />

                            <div class="form-horizontal">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">Precio</label>
                                    <div class="col-sm-9">
                                        <asp:TextBox CssClass="form-control" ID="tbxTipo" runat="server" Text="<%#BindItem.Precio %>" MaxLength="9" />
                                        <asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator1" runat="server" ControlToValidate="tbxTipo"
                                            ErrorMessage=" Campo Necesario" ForeColor="Red"></asp:RequiredFieldValidator>
                                        <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" TargetControlID="tbxTipo"
                                            FilterType="Numbers, Custom" ValidChars="." runat="server"></ajaxToolkit:FilteredTextBoxExtender>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">Descripción</label>
                                    <div class="col-sm-9">
                                        <asp:TextBox CssClass="form-control" ID="tbxDescripcion" runat="server" Text="<%#BindItem.Descripcion %>" MaxLength="50" />
                                        <asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbxDescripcion"
                                            ErrorMessage=" Campo Necesario" ForeColor="Red"></asp:RequiredFieldValidator>
                                        <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" TargetControlID="tbxDescripcion"
                                            FilterType="LowercaseLetters, UppercaseLetters,Custom" ValidChars=" " runat="server"></ajaxToolkit:FilteredTextBoxExtender>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                            <asp:Button class="btn btn-primary" CommandName="insert" ID="btnGuardar" Text="Guardar" runat="server" />
                        </div>
                    </div>
                </div>
            </div>
        </InsertItemTemplate>
        <EditItemTemplate>
            <div class="box box-warning">
                <div class="box-header with-border">
                    <h3 class="box-title">Modificar</h3>
                </div>
                <div class="box-body">
                    <asp:TextBox ID="tbxId" runat="server" Text="<%#BindItem.Id %>" Visible="False" />

                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Precio</label>
                            <div class="col-sm-5">
                                <asp:TextBox CssClass="form-control" ID="tbxTipo" runat="server" Text="<%#BindItem.Precio %>" MaxLength="9" />
                                <asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator1" runat="server" 
                                    ControlToValidate="tbxTipo" ErrorMessage=" Campo Necesario" ForeColor="Red"></asp:RequiredFieldValidator>
                                <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" TargetControlID="tbxTipo"
                                    FilterType="Numbers, Custom" ValidChars="." runat="server"></ajaxToolkit:FilteredTextBoxExtender>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Descripción</label>
                            <div class="col-sm-5">
                                <asp:TextBox CssClass="form-control" ID="tbxDescripcion" runat="server" Text="<%#BindItem.Descripcion %>" MaxLength="50" />
                                <asp:RequiredFieldValidator Display="Dynamic" ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbxDescripcion"
                                    ErrorMessage=" Campo Necesario" ForeColor="Red"></asp:RequiredFieldValidator>
                                <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" TargetControlID="tbxDescripcion"
                                    FilterType="LowercaseLetters, UppercaseLetters,Custom" ValidChars=" " runat="server"></ajaxToolkit:FilteredTextBoxExtender>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="box-footer">
                    <div class="pull-right">
                        <a href="../Acciones/Acciones.aspx" type="button" class="btn btn-default" 
                            onclick='return confirm("¿Esta seguro que desea salir? Los datos nuevos no se guardaran");'>Salir</a>
                        <asp:Button CssClass="btn btn-primary" CommandName="update" ID="btnGuardar" Text="Guardar" runat="server" />
                    </div>
                </div>
            </div>
        </EditItemTemplate>
    </asp:FormView>
</asp:Content>
